<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>出款查询</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#all').click(function(){
			var status=$('#all').attr("checked");
			$("input[name=multiSel]").attr("checked",status);
		});
		
		$('input[name=searchCondition.split]').change(function(){
			var p=$('input[name=searchCondition.split]').attr("checked");
			if(p){
				$('#status').text('是');
			}else{
				$('#status').text('否');
			}
		});
		$('#combine').click(function(){
			if(combineAmt(false)){
				var origin="${searchCondition.amtMax}";//原始拼凑金额				
				var current=$('#amtMax').val();//当前金额
				if(origin==current){
					$('#combineFlag').val('retry');
					$('#ns').text('已重凑!');
				}
			}
		});
		
		$('#amtMax').blur(function(){
			if(combineAmt(false)){
				var origin="${searchCondition.amtMax}";//原始拼凑金额				
				var current=$('#amtMax').val();//当前金额
				if(origin!=current){
					$('#combineFlag').val('retry');
					$('#combine').attr('disabled',true);
				}
				else{
					$('#combine').attr('disabled',false);
				}
			}
		});
		$('#amtMin').blur(function(){
			combineAmt(true);
		});
	});
	//查询结算信息
		function queryCheck(){
				if(!combineAmt(true))//拼凑金额
				{
					return;
				}
				$("#queryUserForm").attr("action","<%=basePath%>/applyMoney/queryApplyMoneyJsp.ct")
				$("#queryUserForm").submit();
				$("#queryBtnId").attr("disabled","true");
				$("#res").attr("disabled","true");
				$("#apply").attr("disabled","true");
				$("#applylist").attr("disabled","true");
		}

		function applyListSimple(){
			var dd = $("input[name=multiSel]:checked");
			if(dd.length == 0){
				alert("请选择记录");
				return false;
			}
			if(applyCheck(false)){
				$("#queryUserForm").attr("action","<%=basePath%>/applyMoney/applyMoneySimpleInit.ct")
				$("#queryUserForm").submit();
				$("#queryBtnId").attr("disabled","true");
				$("#res").attr("disabled","true");
				$("#apply").attr("disabled","true");
				$("#applylist").attr("disabled","true");
			}
		}
		function applyList(){
			if(applyCheck(true)){
				$("#queryUserForm").attr("action","<%=basePath%>/applyMoney/applyMoneyInit.ct")
				$("#queryUserForm").submit();
				$("#queryBtnId").attr("disabled","true");
				$("#res").attr("disabled","true");
				$("#apply").attr("disabled","true");
				$("#applylist").attr("disabled","true");
			}
		}		
		//表单条件校验
		function applyCheck(status){
			if(status){
				var dateMin = $.trim($("#settleDateMin").val());
				var dateMax = $.trim($("#settleDateMax").val());
				if(!dateMin || !dateMax){
					alert("结算起始时间范围必须选择");
					return false;
				}
			}
 			var chanel = $.trim($("#channel").val());
			if(!chanel){
				alert("请选择出款通道");
				return false;
			}
			var remark = $.trim($("#remark").val());
			if(!remark){
				alert("请填写出款备注");
				return false;
			}
			var last=confirm("请仔细检查备注!\n是否确定出款~");
			if(!last){
				return false;
			}
			return true;
		}
		
		//字符串转时间
		function   str2date(str){   
			var   d=null;   
			var   reg=/^(\d{4})(\d{2})(\d{2})$/  ;
			if(arr=str.match(reg)) d=new Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
			return   d;   
		}
		
		
		function combineAmt(status){
			var amtmin=$('#amtMin').val();
			var amtmax=$('#amtMax').val();
			var regex=/^(0|[1-9][0-9]*)(.[0-9]{1,2})?$/;
			if(amtmin){
				if(!regex.test(amtmin)){
					alert("最小值不规范");
					return false;
				}
			}
			if(amtmax){
				if(!regex.test(amtmax)){
					alert("最大值不规范");
					return false;
				}
			}
			if(amtmin&&amtmax){
				if(amtmin>=amtmax){
					alert("最小金额要小于最大金额!");	
					return false;
				}				
			}
			if(status){
				return true;
			}
			if(!amtmax){
				return false;
			}
			return true;
		}
	</script>
</head>
<body>
<s:form id="queryUserForm" action="/applyMoney/queryApplyMoneyJsp.ct" method="post" theme="simple">
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">出款申请</div></td>
        </tr>
		<tr class="tb-line">
            
            <td align="right" class="tb-td">
                <div class="tb-h4">商户号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                <s:textfield name="searchCondition.mchtCd" cssClass="queryWidth"></s:textfield>
                </label>
            </td>
            
            <td align="right" class="tb-td">
                <div class="tb-h4">商户名：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                <s:textfield name="searchCondition.mchtName" cssClass="queryWidth"></s:textfield>
                </label>
            </td>
        </tr>		
        <tr class="tb-line">
            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">银行账号：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-input-normal">
 				 <s:textfield name="searchCondition.accountNo" cssClass="queryWidth"></s:textfield>
 				</label></td>
			<td align="right" class="tb-td">
                <div class="tb-h4">结算日期：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-mini">
                <s:textfield id="settleDateMin" name="searchCondition.applyDateMin" placeholder="起始日期" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});" cssClass="queryWidth"></s:textfield>
                </label>-
                <label class="tb-input-mini">
                <s:textfield id="settleDateMax" name="searchCondition.applyDateMax" placeholder="结束日期" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});" cssClass="queryWidth"></s:textfield>
                </label>
            </td>
            
        </tr>
         <tr class="tb-line">
 
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">机构：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-select">
				 <s:select name="searchCondition.org" list="#{'48502000':'新POSP'}"  cssClass="queryWidth" id="orgCode"/> 
                </label>
             </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">账户性质：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-select">
				 <s:select name="searchCondition.nature" list="#{'01':'对公','02':'对私'}" headerKey="" headerValue="不限" cssClass="queryWidth" id="orgCode"/> 
                </label>
             </td>            
        </tr>
         <tr class="tb-line">
 
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">出款类型：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-select">
				 <s:select name="searchCondition.type" list="#{'0':'普通交易出款','1':'扫码出款','2':'强扣放款'}" headerKey="" headerValue="不限" cssClass="queryWidth" id="orgCode"/> 
                </label>
             </td>                    
        </tr>
        <s:if test="#session.session_merchant.roleType==\"06\" || #session.session_merchant.roleType==\"07\"">
        <tr class="tb-line">
        	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">出款通道：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-select">
				 <s:select name="searchCondition.channel" list="channelList" listKey="code" listValue="name" headerKey="" headerValue="请选择" cssClass="queryWidth" id="channel"/> 
                </label><font color="red">出款必选*</font>             	
            </td>
<%--             <s:hidden name="searchCondition.channel" value="XMYLDF1"></s:hidden>
 --%>			<td align="right" class="tb-td">
                <div class="tb-h4">备注：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                <s:textfield name="searchCondition.remark" cssClass="queryWidth" id="remark" maxlength="100"></s:textfield>               
                </label>
                <font color="red">出款必填*</font>
            </td>
            
        </tr>
        <tr class="tb-line">
        	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">是否拆分金额：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-select">
 				 <samp id="status">否</samp>
				 <input name="searchCondition.split" value="ok" type="checkbox"/>
                </label> 
                <font color="red">出款可选*</font>         	
            </td>      	
            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">拼凑金额(万元)：</div>
            </td>
            <td class="tb-td">
 				<label class="tb-input-mini">
                <s:textfield id="amtMin" name="searchCondition.amtMin" placeholder="最小金额"  cssClass="queryWidth"></s:textfield>
                </label>-
                <label class="tb-input-mini">
                <s:textfield id="amtMax" name="searchCondition.amtMax" placeholder="最大金额"  cssClass="queryWidth"></s:textfield>
                </label>
                <s:hidden id="combineFlag" name="searchCondition.combineFlag"></s:hidden>
                <s:hidden  name="searchCondition.combingName"></s:hidden>
                <s:if test="searchCondition.combineFlag == 'exists'">
                	<input type="button" id="combine" value="重新拼凑"/>
                	 <font color="red" id="ns"></font>
                </s:if>
             </td>          
        </tr>
        </s:if>
		<tr>
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;" id="tips"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
		</tr>
        
        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                    <input id="queryBtnId" type="button" value="查询" onclick="queryCheck()"/>
                </label>
                <label class="tb-input-submit">
                    <input type="reset" id="res" value="取消"/>
                </label>
                <s:if test="#session.session_merchant.roleType==\"06\" || #session.session_merchant.roleType==\"07\"">
                 <label class="tb-input-submit">                  
               	<s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
					   		<input id="apply" type="button" value="同意出款" onclick="applyListSimple()"/>				   
					</s:if>
					<s:else>
					 	<input id="apply" disabled="disabled" value="同意出款" type="button" /> 
					</s:else>
               </label>
                 <label class="tb-input-submit">
               	<s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
					   		<input id="applylist" type="button" value="全部同意出款" onclick="applyList()"/>				   
					</s:if>
					<s:else>
					 	<input id="applylist" disabled="disabled" value="全部同意出款" type="button" /> 
					</s:else>				
               </label>               
               </s:if>
            </td>
        </tr>
        <s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
			<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="4"> <page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/applyMoney/queryApplyMoneyJsp.ct?currentPage=" />

				</td>
			</tr>
		</s:if>
    </tbody>
</table>

<div class="big-tb">
    <table class="tb" style="width: 100%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="16">结算完成信息列表</th>
            </tr>
            <tr class="tb-line bg-gray">
            	<s:if test="#session.session_merchant.roleType==\"06\" || #session.session_merchant.roleType==\"07\"">
            	<s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
                   			<th class="tb-th">
                   			<input id="all" type="checkbox"/>
                   			</th>
                </s:if>
                </s:if>
                <th class="tb-th">商户号</th>
                <th class="tb-th">商户名称</th>                
                <th class="tb-th">账号名称</th>
                <th class="tb-th">结算银行</th>
                <th class="tb-th">结算银行账号</th>               
                <th class="tb-th">出款金额（元）</th>
                <th class="tb-th">商户手续费（元）</th>
                <th class="tb-th">冻结金额（元）</th>
                <th class="tb-th">结算金额（元）</th>               
                <th class="tb-th">交易金额（元）</th>
                <th class="tb-th">出款类型</th>
                <th class="tb-th">账户性质</th>
                <th class="tb-th">结算日期</th>
                <th class="tb-th">出款状态</th>            
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.settleList" status="stat" id="bean">
				<tr  class="tb-line"  >
					<s:if test="#session.session_merchant.roleType==\"06\" || #session.session_merchant.roleType==\"07\"">
					<s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
							<td class="tb-td" align="center">
                   			<input name="multiSel" value="<s:property value="#bean.remark1"/>" type="checkbox" />
                   			</td>
                	</s:if>
                	</s:if>
					<td class="tb-td">
						<s:property value="#bean.mchtCd"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.mchtName"/>
					</td>
					
					<td class="tb-td">
						<s:property value="#bean.accountName"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.bankName"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.account"/>
					</td>				
					<td class="tb-td">
						<s:property value="#bean.unFreezeAmt"/>
					</td>				
					<td class="tb-td">
						<s:property value="#bean.mchtFee"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.freezeAmt"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.mchtSetAmt"/>
					</td>
					<td class="tb-td">
						<s:property value="#bean.transAmt"/>
					</td>
					<td class="tb-td">
						<s:if test="#bean.remark==\"0\" ">
							普通交易出款
						</s:if>
						<s:elseif test="#bean.remark==\"1\"">
							扫码出款
						</s:elseif>
						<s:elseif test="#bean.remark==\"2\"">
							 强扣放款
						</s:elseif>
						<s:else>
							未知
						</s:else>
					</td>
					<td class="tb-td">
						<s:if test="#bean.accType==\"01\" ">
							对公
						</s:if>
						<s:elseif test="#bean.accType==\"02\" ">
							对私
						</s:elseif>
						<s:else>
							未知
						</s:else>
					</td>
					<td class="tb-td">
						<s:property value="#bean.settleDate"/>
					</td>
					<td class="tb-td">
						<s:if test="#bean.settleFlag == 1">
						结算完成
						</s:if>
						<s:else>
						待定
						</s:else>
					</td>
				</tr>
			</s:iterator>
        </tbody>
    </table>
</div>
</s:form>
</body>
</html>